﻿using System;
using RootfusAddinContracts;
using RootfusAddinView;
using System.AddIn.Pipeline;

namespace RootfusAddinAddinSideAdapters
{
    [AddInAdapter]
    public class SICalbackViewToContract : ContractBase, ISICallbackContract
    {
        SICallback _view;

        public SICalbackViewToContract(SICallback view)
        {
            _view = view;
        }

        #region ISICallbackContract Members

        public void UpdateSaveInformation(string xmltext)
        {
            _view.UpdateSaveInformation(xmltext);
        }

        public RootfusAddinContracts.ROOTObjectSpec[] GetConnectedPinDataAsROOTObject(IPinDefinitionContract pin)
        {
            RootfusAddinView.ROOTObjectSpec[] rtn = _view.GetConnectedPinDataAsROOTObject(PinDefinitionHostAdapters.ContractToView(pin));
            return UtilityConverters.ConvertROOTObjectSpecArray(rtn);
        }

        public void OutputPinsChanged()
        {
            _view.OutputPinsChanged();
        }

        public string[] GetNamesOfConnectedPins(IPinDefinitionContract pinDefinition)
        {
            return _view.GetNamesOfConnectedPins(PinDefinitionHostAdapters.ContractToView(pinDefinition));
        }

        #endregion
    }
}
